/*
 * Copyright (c) 2024 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef OHOS_LIBPAG_PAGCOMPOSITIONPROXY_H
#define OHOS_LIBPAG_PAGCOMPOSITIONPROXY_H

#include "pag/pag.h"
#include "hilog/log.h"
#include "napi/native_api.h"

namespace NativeXComponentSample {

extern std::unordered_map<std::string, std::shared_ptr<pag::PAGComposition>> g_pagCompositionMap_;
class PagCompositionProxy {
public:
    explicit PagCompositionProxy(std::string &id);
    PagCompositionProxy();
    ~PagCompositionProxy();
    napi_value PAGCompositionInit(napi_env env, napi_callback_info info);
    napi_value AddLayer(napi_env env, napi_callback_info info);
    napi_value GetLayerAt(napi_env env, napi_callback_info info);
    napi_value RemoveLayer(napi_env env, napi_callback_info info);
    napi_value RemoveAllLayers(napi_env env, napi_callback_info info);
    napi_value JsPlayerConstructor(napi_env env, napi_callback_info info);
    napi_value NumChildren(napi_env env, napi_callback_info info);
    napi_value AddLayerAt(napi_env env, napi_callback_info info);
    napi_value RemoveLayerAt(napi_env env, napi_callback_info info);
    void Destructor(napi_env env, void *nativeObject, void *finalize); // 释放资源的函数(类似类的析构函数)
    napi_ref sJSPlayerConstructor_;                                    // 生命周期变量
    std::string _msg;                                                  // 设置和获取数据的变量
    napi_env mEnv = nullptr;                                           // 记录环境变量
    napi_ref mRef = nullptr;                                           // 记录生命周期变量
    std::string id_;
    static std::unordered_map<std::string, PagCompositionProxy *> PagCompositionProxyMap_;
    std::shared_ptr<pag::PAGComposition> m_pagComposition;
    };
}
#endif //OHOS_LIBPAG_PAGCOMPOSITIONPROXY_H
